<template>
  <view :class="viewClassNames">
    <IBizForm :controller="c"><slot></slot></IBizForm>
  </view>
</template>

<script lang="ts" setup>
import { EditFormController, IControlProvider } from '@ibiz-template/runtime'
import { IDEEditForm } from '@ibiz/model-core'
import { useNamespace, useControlController } from '../use'

const props = defineProps({
  modelData: {
    type: Object as PropType<IDEEditForm>,
    required: true,
  },
  context: { type: Object as PropType<IContext>, required: true },
  params: { type: Object as PropType<IParams>, default: () => ({}) },
  provider: { type: Object as PropType<IControlProvider> },
  isSimple: { type: Boolean, required: false },
  data: { type: Object as PropType<IData>, required: false },
  loadDefault: { type: Boolean, default: true },
})

const c = useControlController((...args) => new EditFormController(...args))
const ns = useNamespace(`control-${c.model.controlType!.toLowerCase()}`)

const viewClassNames = computed(() => [ns.b()])
</script>
